package tenumn.energytech.registrys;

import net.minecraft.core.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.common.util.NonNullSupplier;
import org.jetbrains.annotations.Nullable;

import javax.annotation.Nonnull;
import java.util.Objects;
import java.util.function.Supplier;

public record SimpleCapProvider(Capability<?> cap, NonNullSupplier<?> value) implements ICapabilityProvider
{
    @Nonnull
    @Override
    public <T>  LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side)
    {
        if(cap==this.cap)
        return LazyOptional.of(value).cast();
        return LazyOptional.empty();
    }
}
